/**br axioms

Lucian Green Principia Mathematica
count1 - counts the instances of words in the topic in the raw undeveloped breasonings (relevance), their objection and synthesis, etc., showing that “part of room” is the topic with breasonings with the highest relevancy score, because sentences discuss part of room anyway when writing in the subject-verb-object format.

acceptability of br
- vegan
- positive
nonsexual
nonreligious
()subject-verb-object
()equal chance of subject being male or female
simple object
object instance not mentioned before in argument
on topic
can be synthesised with other br in same argument
()can be repointed to another topic

bug checking br
- single object
right colour
right dimensions
()grammatical**/

%% vegan

%% replace_term1([i, applied, the, cream], [[cream, comfrey_root_extract], [lotion, comfrey_root_extract], [ulcer_treatment, comfrey_root_extract], [wound_treatment, comfrey_root_extract]]).
%% [i, applied, the, comfrey_root_extract]
%% replace_term1([i, applied, the, ulcer_treatment], [[cream, comfrey_root_extract], [lotion, comfrey_root_extract], [ulcer_treatment, comfrey_root_extract], [wound_treatment, comfrey_root_extract]]).
%% [i, applied, the, comfrey_root_extract]

replace_term1(Sentence1, WordReplacementTuples) :-
        replace_term2(Sentence1, WordReplacementTuples, [], Sentence2),
        writeln(Sentence2).
replace_term2([], _WordReplacementTuples, Sentence, Sentence) :- !.
replace_term2(SentenceWords1, WordReplacementTuples, ConstructedSentence1, Sentence) :-
        SentenceWords1=[Word1|SentenceWords2],
        replace(Word1, WordReplacementTuples, Word2),
        append(ConstructedSentence1, [Word2], ConstructedSentence2),
        replace_term2(SentenceWords2, WordReplacementTuples, ConstructedSentence2, Sentence).
replace(Word1, WordReplacementTuples, Word2) :-
        (member([Word1, Word2], WordReplacementTuples);Word1=Word2).

%% positive 
%% replace_term1([i, disagree, with, the, negative, term, that, is_not, positive], [[disagree, agree], [negative, positive], [is_not, is], [are_not, are]]).
%% [i,agree,with,the,positive,term,that,is,positive]

%% nonsexual 
%% replace_term1([i, observed, the, man, insert, his, penis, into, the, anus], [[penis, rod], [vagina, void], [anus, void]]).
%% [i,observed,the,man,insert,his,rod,into,the,void]

%% nonreligious 
%% replace_term1([i, prayed_to, and, meditated_to, god, in, the, lm, centre, after, the, lm, teacher, taught, me, lm], [[prayed_to, wrote_about], [meditated_to, thought_about], [god, the_master], [maharishi, leader], [lm, philosophy]]).
%% [i,wrote_about,and,thought_about,the_master,in,the,philosophy,centre,after,the,philosophy,teacher,taught,me,philosophy]

%% simple object 
%% replace_term1([i, programmed, the, robot, on, the, computer], [[camera, pinhole_camera], [smartphone, pen_and_paper], [universal_translator, interpreter], [robot, shell], [computer, shell]]).
%% [i,programmed,the,shell,on,the,shell]

%% object instance not mentioned before in argument
%% not(member(apple,[beetroot,candle,fan])).
%% true

topic
topic, reason, -br, opp of sugg by br , objection, rebuttal, para conn
decide on setting (business etc of a entity type, in this case, person) for rebuttal to reach from br-reason combination, (person entity type from time to do, object in direction in) para conn.
- conns - recurring expression/doing parts
- obj - opp of sugg by br, choice of br - to reach obj/rebuttal on topic (business, etc for time to do), reason - should be chosen by writer on topic

Table - How sometimes-used reason basis entities, reason entities and connection entities are related for particular topics.  Do they have a nested structure or multiple objects per sentence?  Do the functions invert with greater topic scope?  What would the nature of a continuous, longer program ensuring the essay was on the correct topic be?
topic - sometimes reason basis entity is used - reason entity- connection entity 
breathsoning - n=noun p1=property of noun- j1=judgment of noun
n(p1(j1))
rebreathsoning - o1=object1 o2=object2 j2=judgment of/action after verb o1(j2), o2(j2)
room - p2= property of furnishing in room - f=furnishing in room f(p2)
part of room - p3= part of room j3=judgment in part of room - a=analysis associated with part of room p3(a(j3))
direction  - m=map related to object - o=object o(m)
time to do - s=setting - p4=person p4(s)

/**

orderarg1 - finds the order and argument number in function with structure r1(r2(c)), where r1=reason basis entity, r2=reason entity and c=connection entity.  The nature of these function parts reveals how the essay is on the topic.

Order - 0, 1 and 2 in 0(1(2)) function positions
ArgumentNumber - 0, 1 or 2 in fn in Functions below.
Functions - functions in form [[n,f1],[n+1,f2],…], where n=0 if there is a single item and increments from 1 if there are one or more items, and fn=a(b(c)), a(b), etc…
Name - The name of the function part at the desired order and argument number.

Input and Output

?- orderarg1(0,0,[[0,n(p1(j1))]],Name).
Name = n.

?- orderarg1(1,0,[[0,n(p1(j1))]],Name).
Name = p1.

?- orderarg1(2,0,[[0,n(p1(j1))]],Name).
Name = j1.

?- orderarg1(0,1,[[1,o1(j2)],[2,o2(j2)]],Name).
Name = o1 
false.

?- orderarg1(0,2,[[1,o1(j2)],[2,o2(j2)]],Name).
Name = o2.

?- orderarg1(0,0,[[0,f(p2)]],Name).
Name = f.

?- orderarg1(1,0,[[0,f(p2)]],Name).
Name = p2.

Commands Used

?- f(p2) =.. [_, Part].
Part = p2.

?- functor(f(p2),Part,_NumberOfArgs).
Part = f,
_NumberOfArgs = 1.

**/

orderarg1(Order,ArgumentNumber,Functions1,Name) :-
	member([ArgumentNumber,Function],Functions1),
	orderarg2(Order,Function,Name).
orderarg2(0,Function,Name) :-
	functor(Function,Name,_NumberOfArgs), !.
orderarg2(1,Function1,Name) :-
	Function1 =..[_, Function2],
	functor(Function2,Name,_NumberOfArgs), !.
orderarg2(2,Function1,Name) :-
	Function1 =..[_, Function2],
	Function2 =..[_, Function3],
	functor(Function3,Name,_NumberOfArgs), !.
	
synth
check off each opp obj and rebuttal are on (connected to) topic
give score of how many times topic is mentioned in r1r2c

/**

count1 - counts instances of Item in Lists

Input and Output

count1(judgment_of_noun,[[noun],[property,of,noun],[judgment_of_noun]],Count).
Count = 1 

count1(judgment_of_verb,[[object1],[object2],[judgment_of_verb,action_after_verb]],Count).
Count = 1 

count1(room,[[property,of,furnishing,in,room],[furnishing,in,room]],Count).
Count = 2

count1(part_of_room,[[part_of_room],[judgment,in,part_of_room],[analysis,associated,with,part_of_room]],Count).
Count = 3

count1(direction,[[map,related,to,object],[object]],Count).
Count = 0

count1(time_to_do,[[setting],[person]],Count).
Count = 0

**/

count1(Item,Lists,Count) :-
        count2(Item, Lists, 0, Count).
count2(_Item, [], Count, Count).
count2(Item, Lists1, Count1, Count2) :-
        Lists1=[List|Lists2],
        count3(Item, List, Count1, Count3),
        count2(Item, Lists2, Count3, Count2).
count3(_Item, [], Count, Count).
count3(Item1, List, Count1, Count2) :-
        ((List=[Item1|Items], Count3 is Count1+1);
        (List=[Item2|Items], not(Item1=Item2), Count3 is Count1)),
        count3(Item1,Items,Count3, Count2).